package com.xique.park.controller.auto;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.xique.park.bean.request.comm.ParkOnListRequest;
import com.xique.park.service.biz.service.IParkOnBizService;
import com.xique.park.service.service.ExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkOn;
import com.xique.park.service.service.IParkOnService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 在场车辆Controller
 * 
 * @author xique
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/parkOn")
public class ParkOnController extends BaseController
{
    @Autowired
    private IParkOnService parkOnService;

    @Autowired
    private ExportService exportService;

    /**
     * 查询在场车辆列表
     */
    @PreAuthorize(hasPermi = "park:on:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkOn parkOn)
    {
        startPage();
        List<ParkOn> list = parkOnService.selectParkOnList(parkOn);
        return getDataTable(list);
    }

    /**
     * 导出在场车辆列表
     */
    @PreAuthorize(hasPermi = "park:on:export")
    @Log(title = "在场车辆", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkOnListRequest request) throws IOException
    {
        exportService.exportParkOnList(response,request);
    }

    /**
     * 获取在场车辆详细信息
     */
    @PreAuthorize(hasPermi = "park:on:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkOnService.selectParkOnById(id));
    }

    /**
     * 新增在场车辆
     */
    @PreAuthorize(hasPermi = "park:on:add")
    @Log(title = "在场车辆", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkOn parkOn)
    {
        return toAjax(parkOnService.insertParkOn(parkOn));
    }

    /**
     * 修改在场车辆
     */
    @PreAuthorize(hasPermi = "park:on:edit")
    @Log(title = "在场车辆", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkOn parkOn)
    {
        return toAjax(parkOnService.updateParkOn(parkOn));
    }

/*    *//**
     * 删除在场车辆
     *//*
    @PreAuthorize(hasPermi = "park:on:remove")
    @Log(title = "在场车辆", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkOnService.deleteParkOnByIds(ids));
    }*/
}
